package com.example.invoicing.pojo;

import java.util.List;

public class PageResult {
    // 当前页
    private int currentPage;
    // 每页显示的总条数
    private int pageSize;
    // 总条数
    private int totalSize;
    // 总页数
    private int totalPage;
    // 开始索引
    private int startIndex;

    private List<?> items;

    public int getCurrentPage() {
        return this.currentPage;
    }

    public void setCurrentPage(final int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(final int pageSize) {
        this.pageSize = pageSize;
        this.startIndex = (this.currentPage - 1) * this.pageSize;
    }

    public int getTotalSize() {
        return this.totalSize;
    }

    public void setTotalSize(final int totalSize) {
        this.totalSize = totalSize;
        this.totalPage = (int)(Math.ceil(this.totalSize * 1.0 / this.pageSize));
    }

    public int getTotalPage() {
        return this.totalPage;
    }

    public void setTotalPage(final int totalPage) {
        this.totalPage = totalPage;
    }

    public int getStartIndex() {
        return this.startIndex;
    }

    public void setStartIndex(final int startIndex) {
        this.startIndex = startIndex;
    }

    public List<?> getItems() {
        return this.items;
    }

    public void setItems(final List<?> items) {
        this.items = items;
    }

    @Override
    public String toString() {
        return "{" +
                "currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", totalSize=" + totalSize +
                ", totalPage=" + totalPage +
                ", startIndex=" + startIndex +
                ", items=" + items +
                '}';
    }
}
